package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhFactoryBalanceDetails;
import com.ruoyi.zsyh.service.IZsyhFactoryBalanceDetailsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 厂家余额变动明细Controller
 * 
 * @author yuexl
 * @date 2022-01-04
 */
@Controller
@RequestMapping("/zsyh/factoryBalanceDetails")
public class ZsyhFactoryBalanceDetailsController extends BaseController
{
    private String prefix = "zsyh/factoryBalanceDetails";

    @Autowired
    private IZsyhFactoryBalanceDetailsService zsyhFactoryBalanceDetailsService;

    @RequiresPermissions("zsyh:factoryBalanceDetails:view")
    @GetMapping()
    public String factoryBalanceDetails()
    {
        return prefix + "/factoryBalanceDetails";
    }

    /**
     * 查询厂家余额变动明细列表
     */
    @RequiresPermissions("zsyh:factoryBalanceDetails:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhFactoryBalanceDetails zsyhFactoryBalanceDetails)
    {
        startPage();
        List<ZsyhFactoryBalanceDetails> list = zsyhFactoryBalanceDetailsService.selectZsyhFactoryBalanceDetailsList(zsyhFactoryBalanceDetails);
        return getDataTable(list);
    }

    /**
     * 导出厂家余额变动明细列表
     */
    @RequiresPermissions("zsyh:factoryBalanceDetails:export")
    @Log(title = "厂家余额变动明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhFactoryBalanceDetails zsyhFactoryBalanceDetails)
    {
        List<ZsyhFactoryBalanceDetails> list = zsyhFactoryBalanceDetailsService.selectZsyhFactoryBalanceDetailsList(zsyhFactoryBalanceDetails);
        ExcelUtil<ZsyhFactoryBalanceDetails> util = new ExcelUtil<ZsyhFactoryBalanceDetails>(ZsyhFactoryBalanceDetails.class);
        return util.exportExcel(list, "厂家余额变动明细数据");
    }

    /**
     * 新增厂家余额变动明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存厂家余额变动明细
     */
    @RequiresPermissions("zsyh:factoryBalanceDetails:add")
    @Log(title = "厂家余额变动明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhFactoryBalanceDetails zsyhFactoryBalanceDetails)
    {
        return toAjax(zsyhFactoryBalanceDetailsService.insertZsyhFactoryBalanceDetails(zsyhFactoryBalanceDetails));
    }

    /**
     * 修改厂家余额变动明细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZsyhFactoryBalanceDetails zsyhFactoryBalanceDetails = zsyhFactoryBalanceDetailsService.selectZsyhFactoryBalanceDetailsById(id);
        mmap.put("zsyhFactoryBalanceDetails", zsyhFactoryBalanceDetails);
        return prefix + "/edit";
    }

    /**
     * 修改保存厂家余额变动明细
     */
    @RequiresPermissions("zsyh:factoryBalanceDetails:edit")
    @Log(title = "厂家余额变动明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhFactoryBalanceDetails zsyhFactoryBalanceDetails)
    {
        return toAjax(zsyhFactoryBalanceDetailsService.updateZsyhFactoryBalanceDetails(zsyhFactoryBalanceDetails));
    }

    /**
     * 删除厂家余额变动明细
     */
    @RequiresPermissions("zsyh:factoryBalanceDetails:remove")
    @Log(title = "厂家余额变动明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhFactoryBalanceDetailsService.deleteZsyhFactoryBalanceDetailsByIds(ids));
    }
}
